/**
 * 查看字段审计日志窗口
 */
Ext.namespace("Ext.ux.syslog");

Ext.ux.syslog.PropAuditDetailWindow = Ext.extend(Ext.Window, {

	width: 780,
	height: 420,
	layout: 'fit',
	plain : true,
	modal: true,
	border: false,
	
	detailPanel: null,

	initComponent:function(){
		Ext.ux.syslog.PropAuditDetailWindow.superclass.initComponent.call(this);
		
		// 编辑附件数据时的JSON解析
		var formReader = new Ext.data.JsonReader({
			root: 'result',
			totalProperty: 'totalCount',
			id : 'id'
		},[
			{name: 'id', mapping: 'id'}, 
			{name: 'entity', mapping: 'entity'}, 
			{name: 'entityId', mapping: 'entityId'}, 
			{name: 'propertyName', mapping: 'propertyName'},
			{name: 'propertyComment', mapping: 'propertyComment'},
			{name: 'oldValue', mapping: 'oldValue'},
			{name: 'newValue', mapping: 'newValue'},
			{name: 'updator', mapping: 'updator'},
			{name: 'updateTime', mapping: 'updateTime', type: 'date', dateFormat: 'Y-m-d H:i:s'},
			{name: 'memo', mapping: 'memo'}
		]);

	
		var inputPanel = new Ext.form.FormPanel({
    		labelAlign: 'right',
       		frame: true,
       		reader: formReader,
        	bodyStyle: 'padding:5px 5px 0',
       		width: 300,
       		items: [{
       		 	layout: 'form',
       		 	xtype: 'fieldset',
		        title: '<span class="fs_tip">标志 <span class="fs_flag">*</span> 字段为必填项</span>',
	       		items:[{
	       			layout: 'column',
		       		items:[{
		       			columnWidth: .5,
		       			layout: 'form',
		       			items: [{
							xtype: 'hidden',
							name: 'id'
						},{
			       			fieldLabel: '<span class="fs_flag">*</span>&nbsp;值对象名称',
			       			name: 'entity',
			       			xtype: 'textfield',
			       			anchor: '95%'
		       		 	}]
		       		},{
		       			columnWidth: .5,
		       			layout: 'form',
		       			items: [{
		       		 		fieldLabel: '<span class="fs_flag">*</span>&nbsp;值对象主键',
		       		 		name: 'entityId',
		       		 		xtype: 'textfield',
		       		 		anchor: '95%'
		       			}]
		       		}]
				},{
	       			layout: 'column',
		       		items:[{
		       			columnWidth: .5,
		       			layout: 'form',
		       			items: [{
			       			fieldLabel: '属性名称',
			       			name: 'propertyName',
			       			xtype: 'textfield',
			       			anchor: '95%'
		       		 	}]
		       		},{
		       			columnWidth: .5,
		       			layout: 'form',
		       			items: [{
		       		 		fieldLabel: '属性中文注释',
			       			name: 'propertyComment',
			       			xtype: 'textfield',
			       			anchor: '95%'
		       			}]
		       		}]
				},{
		       		 	layout: 'column',
		       		 	items:[{
		       		 		columnWidth: 1,
		       		 		layout: 'form',
		       		 		items: [{
		       		 		   	fieldLabel: '旧值',
		       		 			xtype: 'textarea',
		       		 			name: 'oldValue',
		       		 			anchor: '97%'
		       		 		}]
		       		 	}]
	       		 },{
		       		 	layout: 'column',
		       		 	items:[{
		       		 		columnWidth: 1,
		       		 		layout: 'form',
		       		 		items: [{
		       		 		   	fieldLabel: '新值',
		       		 			xtype: 'textarea',
		       		 			name: 'newValue',
		       		 			anchor: '97%'
		       		 		}]
		       		 	}]
	       		 },{
		       		 	layout: 'column',
		       		 	items:[{
		       		 		columnWidth: .5,
		       		 		layout: 'form',
		       		 		items: [{
		       		 			 fieldLabel: '<span class="fs_flag">*</span>&nbsp;修改人',
			       		 		xtype: 'textfield',
			       		 		name: 'updator',
			       		 		anchor: '95%'
		       		 		}]
		       		 		
		       		 	},{
		       		 		columnWidth: .5,
		       		 		layout: 'form',
		       		 		items: [{
		       		 			fieldLabel: '<span class="fs_flag">*</span>&nbsp;修改时间',
			       		 		xtype: 'datefield',
			       		 		format: 'Y-m-d H:i:s',
			       		 		name: 'updateTime',
			       		 		anchor: '95%'
		       		 		}]
		       		 	}]
	       		 },{
		       		 	layout: 'column',
		       		 	items:[{
		       		 		columnWidth: 1,
		       		 		layout: 'form',
		       		 		items: [{
		       		 			fieldLabel: '备注',
			       		 		xtype: 'textarea',
			       		 		name: 'memo',
			       		 		anchor: '97%'
		       		 		}]
		       		 		
		       		 	}]
	       		 }]
       		 }],
       		 buttons: [{
				text: '&nbsp;&nbsp;关闭窗口',
				width: 90,
				iconCls: 'icon-middle-cancel',
				scale: 'medium',
				handler: function(){
					this.close();
				},
				scope: this
			}]
    	});
		
    	this.add(inputPanel); 
    	this.detailPanel = inputPanel;
	},
	
	//加载附件数据
	loadById: function(id){
		this.detailPanel.form.load({
			url: 'sys-prop-audit-log!input.action?id=' + id,
			waitMsg: '正在载入数据...',
			failure: function() {
				Ext.Msg.alert('系统提示', '无法加载指定日志信息！');
			}
		});
		this.show();
	}

});